package calao.plan.client;

import com.google.gwt.user.client.rpc.RemoteService;

import calao.client.MissingPermissionException;
import calao.client.NotConnectedException;

/** Task planning service.
 * This service accepts two types of tasks:
 * <ul>
 * <li> Fixed tasks: tasks with a fixed start and a fixed end.
 * <li> Floating tasks: such tasks are automatically scheduled by the system based on 
 * the worktime required to finish them.
 * </ul>
 * Tasks that are not assigned are not taken into account in the schedule.
 * Floating tasks eventually become fixed tasks. Their start-date is set when they are 
 * declared started by the user they are assigned to. Their end-date is set when they 
 * are declared completed, thus becoming fixed tasks. 
 */
public interface PlanService 
extends RemoteService
{

	/** Creates a resource.
	 */
	public Resource createResource(WorkPeriod[] workPeriods)
	throws NotConnectedException, MissingPermissionException;
	
	/** Gets details of a resource.
	 * 
	 * @param rid the resource identifier.
	 */
	public Resource getResource(int rid)
	throws NotConnectedException, MissingPermissionException;
	
	/** Modifies resource details.
	 */
	public void modifyResource(Resource resourceDetails)
	throws NotConnectedException, MissingPermissionException;
		
	/** Gets details of a task.
	 * 
	 * @param tid the task identifier.
	 */
	public Task[] getTasks(int[] tids)
	throws NotConnectedException, MissingPermissionException;
	
	/** Saves tasks.
	 * This method handles tasks with zero or negative identifiers as new tasks, and sets
	 * valid identifiers for these tasks.
	 */
	public Task[] saveTasks(Task[] taskDetails)
	throws NotConnectedException, MissingPermissionException;
		
	/** Gets all tasks that overlap a period of time.
	 * @param periodStart the target period start date.
	 * @param periodEnd the target period end date.
	 * @return An array of TaskInfo objects describing all tasks in the target period.
	 */ 
	public Task[] getPeriodTasks(long periodStart, long periodEnd)
	throws NotConnectedException, MissingPermissionException;
	
	/** Deletes a task.
	 */
	public void deleteTask(int task)
	throws NotConnectedException, MissingPermissionException;

}
